package com.gongpingjialoan.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.gongpingjialoan.R;

import java.util.List;

public class CarListMenuAdapter extends BaseAdapter {

	LayoutInflater mLayoutInflater;

	Context context;

	List<String> list;

	int pos;

	public CarListMenuAdapter(Context context) {
		this.context = context;
		mLayoutInflater = LayoutInflater.from(context);
	}


	public void setPos(int pos) {
		this.pos = pos;
		notifyDataSetChanged();
	}

	public void setData(List<String> list) {
		this.list = list;
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		if (list == null) {
			return 0;
		}
		return list.size();
	}

	@Override
	public String getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}


	@Override
	public View getView(int position, View v, ViewGroup arg2) {
		if (v == null) {
			v = mLayoutInflater.from(context).inflate(R.layout.item_car_list_menu_list, null);
		}
		String text = getItem(position);
		TextView textT = (TextView) v.findViewById(R.id.title_txt);
		if(pos == position){
			textT.setTextColor(Color.parseColor("#567fbc"));
		}else{
			textT.setTextColor(Color.parseColor("#4a576c"));
		}
		textT.setText(text);
		return v;
	}
}
